﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ServiceModel.Syndication;

namespace GeoSyndication.Common
{
    public static class Utility
    {
        #region Public Methods

        public static Uri CreateUri(string link)
        {
            try
            {
                return new Uri(link);
            }
            catch
            {
                return null;
            }
        }

        public static void BindCategories(string[] categories, SyndicationItem item)
        {
            for (int i = 0; i < categories.Length; i++)
            {
                if (categories[i].Trim() != string.Empty)
                    item.Categories.Add(new SyndicationCategory(categories[i]));
            }
        }

        public static string GetSequenceOfPoints(Point[] line)
        {
            StringBuilder xml = new StringBuilder();

            foreach (Point x in line)
            {
                xml.Append(x.ToString() + " ");
            }

            return xml.ToString();
        }

        public static string[] ParseCategories(string categories)
        {
            string[] retVal = categories.Split('\n');
            return retVal;
        }

        #endregion
    }
}
